<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

include 'securities.php';

class Config extends Securities {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$data['title']="Store Config";
		$this->form_validation->set_rules('company','lang:form_label_username','required');
		$this->form_validation->set_rules('email','lang:form_label_email','required|valid_email');
		$this->form_validation->set_rules('address','lang:form_label_first_name','required');
		$this->form_validation->set_rules('phone','lang:form_label_last_name','required');
		
		if($this->form_validation->run()===FALSE){
			$this->load->view(B_MASTER.'index',$data);	
		}else{
			$data=array(
				'company'=>$this->input->post('company'),
				'address'=>$this->input->post('address'),
				'email'=>$this->input->post('email'),
				'employee'=>$this->input->post('employee'),
				'hand_phone'=>$this->input->post('hand_phone'),
				'language'=>$this->input->post('language'),
				'phone'=>$this->input->post('phone'),
				'website'=>$this->input->post('website')
			);
			
			$is_updated=$this->mod_config->batch_save($data);
			if($is_updated){
				$this->session->set_flashdata('success','Company information was updated success');
				redirect('config');	
			}else{
				$this->session->set_flashdata('error','Company information was updated success');
				redirect('config');
			}
		}
		
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */